<?php
namespace app\admin\controller;
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/10/17
 * Time: 16:07
 */
use think\Controller;
use think\Db;
class Api extends Controller
{
    function jiekou(){

//        获取商品详情
//        $info = request()->param();
//        方便开发测试
        /**
         *
         * id   商品id
         * 10001 返回数据为空
         * 10002 调用成功
         *
         */
        $info = array(
            'id' => 1,
            'jiekou_info' => 'kkkkk_jiukou'
        );
        if($info['jiekou_info'] == 'kkkkk_jiukou'){
            $data = Db::table('goods')
                ->where('good_id = '.$info['id'])
                ->find();
            switch ($data){
                case '';
                    $data['sn'] = 10001;
                    break;
                case '';
                    $data['sn'] = 10002;
                    break;
            }
            return json_encode($data);
        }else{
            return $data['sn'] = 10003;
        }
    }
    function jiek(){
//        获取商品详情
        $info = request()->param();
//        方便开发测试

        /**
         *
         * id   商品id
         * 10001 返回数据为空
         * 10002 调用成功
         *
         */
//        $info = array(
//            'id' => 1,
//            'jiekou_info' => 'kkkkk_jiukou'
//        );
        $data = Db::table('goods')
            ->where('good_id = '.$info['id'])
            ->find();
        switch ($data){
            case '';
                $data['sn'] = 10001;
                break;
            case '';
                $data['sn'] = 10002;
                break;
        }

        return json_encode($data);
    }
}